//
//  SencondViewController.m
//  CNKICommunity
//
//  Created by wei on 17/1/22.
//  Copyright © 2017年 CNKI. All rights reserved.
//

#import "SencondViewController.h"
#import "UIImage+Extension.h"
#import "CNKIAnswerTableViewCell.h"
#import "CNKIAnswerModel.h"

@interface SencondViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *AnswerArr;

@end

@implementation SencondViewController

-(NSMutableArray *)AnswerArr
{
    if (!_AnswerArr)
    {
        _AnswerArr = [NSMutableArray array];
    }
    return _AnswerArr;
}




- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT) style:UITableViewStylePlain];
  
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0);
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
    
    [tableView registerNib:[UINib nibWithNibName:NSStringFromClass([CNKIAnswerTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"answerID"];
    //[tableView registerClass:[TestTableViewCell class] forCellReuseIdentifier:@"answerI"];
    
   NSString *test = [NSString stringWithFormat:@"船动湖光滟滟秋--翠棹，\n含看年少信船流--年少。"];
   
    for (int i = 0; i < 50; i++)
    {
        CNKIAnswerModel *model = [CNKIAnswerModel new];
        test = [test stringByAppendingString:@"\n船动湖光滟滟秋--翠棹"];
        model.WordText = test;
        model.isLove = YES;
        model.type = @"ispicture";
        if (i == 0||i == 5||i == 8)
        {
           model.type = @"Nopicture";
        }
        [self.AnswerArr addObject:model];
    }
    [self.view addSubview:tableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.AnswerArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CNKIAnswerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"answerID"];
    cell.AnswerModel = self.AnswerArr[indexPath.row];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CNKIAnswerModel *model = self.AnswerArr[indexPath.row];
    return model.cellHeight + 1;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
